srcdir=src/
objdir=obj/
bindir=bin/
includedir=src/
includeLibs=-I../../Glow/src -I../../Glow/externLibs
CXX=g++
CXXFLAGS=-fPIC -Wall -s -O2
LDFLAGS=-L../../Glow/lib -lGlow -lpthread
EXE=glowdemo
SRC= $(wildcard $(srcdir)*.cpp)
OBJ= $(SRC:%.cpp=$(objdir)%.o)

all: depend $(EXE)

$(EXE): $(OBJ)
	$(CXX) -o $(bindir)$@ $^ $(LDFLAGS) $(CXXFLAGS)

depend: 
	$(CXX) -MM $(SRC) >depend

-include depend

$(objdir)%.o: %.cpp
	$(CXX) -o $@ -c $< $(CXXFLAGS) -I$(includedir) $(includeLibs)

.PHONY: install clean cleaninstall mrproper

install:
	rm -rf /usr/lib/Glow
	mkdir /usr/lib/Glow
	cp lib/libGlow.so /usr/lib/Glow/
	rm -rf /usr/include/Glow
	cp -r src/ /usr/include/Glow
	rm -rf /usr/lib/libGlow.so*
	ln -s /usr/lib/Glow/libGlow.so /usr/lib/libGlow.so
	ldconfig

clean:
	rm -rf $(objdir)*.o
	rm -rf $(objdir)*/*.o

cleaninstall:
	rm -rf /usr/lib/Glow
	rm -rf /usr/include/Glow
	rm -rf /usr/lib/libGlow.so*

mrproper: clean
	rm -rf $(bindir)$(EXE)
	rm -rf $(includedir)*~
	rm -rf $(srcdir)*~
	rm -rf *~
